/*****************************************************************************
 * at24cxx.h
 *
 * Copyright (C) 2020 Jeasonvor <1101627719@qq.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/

#ifndef __AT24CXX_H__
#define __AT24CXX_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

#define DEVICE_AT24C01  1
#define DEVICE_AT24C02  2
#define DEVICE_AT24C04  3
#define DEVICE_AT24C08  4
#define DEVICE_AT24C16  5
#define DEVICE_AT24C32  6
#define DEVICE_AT24C64  7
#define DEVICE_AT24C128 8
#define DEVICE_AT24C256 9

#define DEVICE_TYPE DEVICE_AT24C02

/*****************************************************************************
 * Public Types
 ****************************************************************************/

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/*
 * @brief:  器件初始化
 *
 * @param[in]:  readbyte    -   读一个字节回调
 * @param[in]:  writebyte   -   写一个字节回调
 *
 * @return: 成功  -   返回0
 *          失败    -   返回其他
 */
int at24cxx_init(uint8_t (*readbyte)(uint16_t addr),
                 void (*writebyte)(uint16_t addr, uint8_t *wData));

/*
 * @brief:  读器件数据
 *
 * @param[in]:  addr    -   数据地址
 * @param[out]: rData   -   读数据指针
 * @param[in]:  len     -   读数据长度
 *
 * @return: 成功  -   返回0
 *          失败    -   返回其他
 */
int at24cxx_read(uint16_t addr, uint8_t *rData, uint16_t len);

/*
 * @brief:  写器件数据
 *
 * @param[in]:  addr    -   数据地址
 * @param[in]:  wData   -   写数据指针
 * @param[in]:  len     -   写数据长度
 *
 * @return: 成功  -   返回0
 *          失败    -   返回其他
 */
int at24cxx_write(uint16_t addr, uint8_t *wData, uint16_t len);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __AT24CXX_H__ */
/****************************************************************************/
/**
 * @} (end addtogroup demo)
 */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
